<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 100px;
            height: 100px;
            background-color: red;
        }
    </style>
</head>

<body>
    <button>开灯</button>
    <button>关灯</button>
    <div></div>
</body>

</html>
<script src="jQuery版本/jquery-3.6.0.js"></script>
<script>
    $(function() {
        var btns = document.getElementsByTagName('button');
        btns[0].onclick = function() {
            $('body').css('backgroundColor', '#ccc');
        }
        $(btns[1]).click(function() {
            $('body')[0].style.backgroundColor = 'white';
        });
    });
</script>